package com.toocms.jinjuhang.ui.mine.management_system.order_details

import android.os.Bundle
import androidx.databinding.ObservableBoolean
import androidx.databinding.ObservableField
import com.blankj.utilcode.util.StringUtils
import com.toocms.jinjuhang.config.Constants
import com.toocms.jinjuhang.data.center.OrganizationOrdersItemData
import com.toocms.jinjuhang.ui.mine.order.details.OrderDetailsFgt
import com.toocms.tab.base.BaseViewModel
import com.toocms.tab.base.ItemViewModel
import com.toocms.tab.binding.command.BindingAction
import com.toocms.tab.binding.command.BindingCommand

class ManagementSystemOrderDetailsRecordItemModel(
    viewModel: ManagementSystemOrderDetailsModel,
    val item: ObservableField<OrganizationOrdersItemData>
) :
    ItemViewModel<BaseViewModel<*>>(viewModel) {

    val isVisible: ObservableBoolean = ObservableBoolean(
        !StringUtils.equals(
            viewModel.type,
            Constants.Extra.IDENTITY_TYPE_COMMISSIONER
        )
    );

    val viewDetailsClickBindingCommand = BindingCommand<BindingAction>(BindingAction {
        item.get()?.apply {
            val bundle = Bundle()
            bundle.putString(Constants.BundleKey.KEY_MEMBER_ID, member_id)
            bundle.putString(Constants.BundleKey.KEY_ORDER_ID, order_id)
            viewModel.startFragment(OrderDetailsFgt::class.java, bundle)
        }
    })
}